//-------------------------------------------------------------------
//	Copyright (c) 2012-2014 Zhirnov Andrey
//	This file is part of the "UXGEN-ES" project.
//	See copyright notice in "Engine.h".
//-------------------------------------------------------------------

#pragma once

#include "UI/Types/Types.h"

namespace Engine
{
namespace UI
{

	//
	// Update Widget Data
	//

	struct UpdateWidgetData
	{
	// types
	public:
		enum ETouchType
		{
			NONE	= 0,
			PRESSED	= 1 << 0,
			CLICK	= 1 << 1,
			MOTION	= 1 << 2,
		};


	// variables
	public:
		// touch //
		vec2		touchPos;		// CLICK, MOTION - start
		vec2		touchDelta;		// MOTION
		vec2		touchSize;		// size of touch area
		ETouchType	touchType;

		// draw //
		int			widgetsChanged;


	// methods
	public:
		UpdateWidgetData () :
			touchType(NONE), widgetsChanged(0)
		{}

		bool IsPressed ()	const		{ return EnumCmp( touchType, PRESSED ); }
		bool IsClicked ()	const		{ return EnumCmp( touchType, CLICK   ); }
		bool InMotion ()	const		{ return EnumCmp( touchType, MOTION  ); }

		rect TouchArea ()	const		{ return rect( touchPos, touchPos ) + rect( -touchSize, touchSize ) * 0.5f; }

		void Reset ()
		{
			*this = UpdateWidgetData();
		}

		void ResetTouch ()
		{
			touchPos	= vec2();
			touchDelta	= vec2();
			touchSize	= vec2();
			touchType	= NONE;
		}
	};


}	// UI
}	// Engine
